feat(param-menu): feature: menu with params #845
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
有些时候需要左侧菜单携带动态参数(params)
实现方案:
guard
(paramMenuGuard.ts),放置于createPermissionGuard
之后(即需要先生成菜单,再进行修改)FrontMenuList
与BackMenuList
)(BackMode
/RouteMappingMode
):paramKey
的参数组,与to.params
进行一一匹配替换path
填装到menu
中,同时需要保留原path
,故于types (interface Menu)
新增了属性paramPath?: string
path
保留至paramPath
中,完成操作。示例如图
自己项目示例:
vben-admin示例:
说明
经测试,自己项目的面包屑无法正常导航,但vben-admin中可以,还没查原因。
建议:
permissionStore
可新增一个方法,getMenuList
,内部判断模式,最终输出当前使用的菜单。